import {AxiosPromise} from "axios";
import request from "@/utils/request";
import {GroupItem, GroupPageResult, GroupQueryParam} from "@/types/system/group";

/**
 * 获取用户分页列表
 *
 * @param queryParams
 */
export function listGroupPages(queryParams: GroupQueryParam): AxiosPromise<GroupPageResult> {
  return request({
    url: '/group/listByPage',
    method: 'get',
    params: queryParams,
  });
}
/**
 * 获取所有用户组表列表-带用户数据的
 *
 */
export function listGroupTree(): AxiosPromise<GroupItem[]> {
  return request({
    url: '/group/listTree',
    method: 'get',
  });
}
/**
 * 获取用户组列表
 *
 */
export function listGroup(): AxiosPromise<GroupItem[]> {
  return request({
    url: '/group/listAll',
    method: 'get',
  });
}


/**
 * 新增用户组
 */
export function addGroup(data: GroupItem) {
  return request({
    url: '/group/add',
    method: 'post',
    data: data,
  });
}

/**
 * 修改用户组
 */
export function updateGroup(id: string, data: GroupItem) {
  return request({
    url: '/group/updateById/' + id,
    method: 'put',
    data: data,
  });
}


/**
 * 批量删除用户组，多个以英文逗号(,)分割
 *
 * @param ids
 */
export function deleteGroups(ids: string) {
  return request({
    url: '/group/delete/' + ids,
    method: 'delete',
  });
}
